High-precision arithmetic is useful in computer programs that are directed to solving problems in certain disciplines. Similar classes of applications may also require arbitrary size arithmetic.
While arithmetic data sizes of 32 or 64 bits are sufficient for many applications, some highly-specialized applications may require hundreds or thousands of bits of precision. When dealing with very large numbers, relatively small—yet significant—changes will be lost with limited precision. For example, when dealing with a double precision datatype, 10^30+1 billion=10^30. In other words, 1 billion is lost in the computation. Many supercomputing application such as physics modeling and numerical methods suffer from accumulated errors due to limited-precision rounding. In another example, some supercomputing applications, such as astrophysics and encryption, deal with extremely large numbers. An “int” datatype typically offers 32 bits of size and supports values in the range of 4 billion, and the “double” datatype offers 1024 bits of size and supports values in the range of 10^400. For these applications, the range provided by “int” and “double” datatypes may be insufficient.
Special libraries have been developed to accommodate high-precision arithmetic. An example library of functions that supports arbitrary precision arithmetic is the GNU MP (GMP) library. The GMP library provides special functions that are available for use in manipulating high-precision data. To arithmetically manipulate high-precision data with the GMP library, a user must learn the names, behavior, and parameters of various specialized functions provided in the library. Thus, there is a significant learning curve that accompanies use of the GMP library. Failure to use the library correctly can lead to program failure or unexpected results.
A method and apparatus that addresses the aforementioned problems, as well as other related problems, are therefore desirable.